#include<bits/stdc++.h>
#define ll long long
#define str string
#define db double
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define ms(x,t) memset(x,t,sizeof(x))
using namespace std;
const int maxn = 2e5+10;
const int maxm = 1e7+10;
const ll INF = 0x3f3f3f3f;
const ll mod = 1e9+7;
int n,Q;
struct SQ {
	int lx,ly,rx,ry;
}a[maxn];
int T = 300; 
struct Query {
	int l,r,id;
	bool operator<(const Query &x) const {
		if(r/T == x.r/T) return ((l < x.l)^((r/T)&1));
		return r/T < x.r/T;
	}
}q[maxn];
struct Node {
	int s[2][2];
	ll sum,tg;
}t[maxm];
const int L = 1e9;
int mx;
int rt,tot;
int Lx,Ly;
vector<int> dx,dy;
struct Seg{
	void add(int &p,const SQ &x,int v,int lx = 0,int rx = Lx-1,int ly = 0,int ry = Ly-1) {
		if(ry < ly || rx < lx) return;
		if(!p) p = ++tot;
//		if(tot % 1000 == 0) cerr<<p<<' '<<x.lx<<' '<<x.rx<<' '<<x.ly<<' '<<x.ry<<' '<<v<<' '<<lx<<' '<<rx<<' '<<ly<<' '<<ry<<' '<<1ll * (dx[rx+1]-dx[lx]) * (dy[ry+1]-dy[ly])<<'\n';
		if(x.lx <= lx && rx <= x.rx && x.ly <= ly && ry <= x.ry) {
			t[p].tg += v;
			if(t[p].tg) t[p].sum = 1ll * (dx[rx+1]-dx[lx]) * (dy[ry+1]-dy[ly]);
			else t[p].sum = t[t[p].s[0][0]].sum + t[t[p].s[1][0]].sum + t[t[p].s[0][1]].sum + t[t[p].s[1][1]].sum;
			return;
		}
		int midx = (lx+rx)>>1,midy = (ly+ry)>>1;
		if(x.lx <= midx && x.ly <= midy) add(t[p].s[0][0],x,v,lx,midx,ly,midy);
		if(x.rx > midx && x.ly <= midy) add(t[p].s[1][0],x,v,midx+1,rx,ly,midy);
		if(x.lx <= midx && x.ry > midy) add(t[p].s[0][1],x,v,lx,midx,midy+1,ry);
		if(x.rx > midx && x.ry > midy) add(t[p].s[1][1],x,v,midx+1,rx,midy+1,ry);
		if(t[p].tg) t[p].sum = 1ll * (dx[rx+1]-dx[lx]) * (dy[ry+1]-dy[ly]);
		else t[p].sum = t[t[p].s[0][0]].sum + t[t[p].s[1][0]].sum + t[t[p].s[0][1]].sum + t[t[p].s[1][1]].sum;
	}
}tr;
int l = 1,r = 0;
int cnt;
void addr() { r++; tr.add(rt,a[r],1); cnt++;}
void addl() { tr.add(rt,a[l],-1); l++; cnt++; }
void delr() { tr.add(rt,a[r],-1); r--; cnt++; }
void dell() { l--; tr.add(rt,a[l],1); cnt++; }
ll ans[maxn];
void Solve() {
	cin >> n >> Q;
	for(int i = 1; i <= n; i++) {
		cin >> a[i].lx >> a[i].ly >> a[i].rx >> a[i].ry;
		dx.pb(a[i].lx); dx.pb(a[i].rx); dy.pb(a[i].ly); dy.pb(a[i].ry);
		mx = max(mx,a[i].rx);
	}
	sort(all(dx)); dx.erase(unique(all(dx)),dx.end()); Lx = dx.size()-1; 
	sort(all(dy)); dy.erase(unique(all(dy)),dy.end()); Ly = dy.size()-1;
	for(int i = 1; i <= n; i++) {
		a[i].lx = lower_bound(all(dx),a[i].lx)-dx.begin();
		a[i].rx = lower_bound(all(dx),a[i].rx)-dx.begin()-1;
		a[i].ly = lower_bound(all(dy),a[i].ly)-dy.begin();
		a[i].ry = lower_bound(all(dy),a[i].ry)-dy.begin()-1;
	}
//	T = sqrt(Q);
	for(int i = 1; i <= n; i++) {
		cin >> q[i].l >> q[i].r; q[i].id = i;
	}
	sort(q+1,q+Q+1);
	for(int i = 1; i <= Q; i++) {
		while(r < q[i].r) addr();
		while(l > q[i].l) dell();
		while(r > q[i].r) delr();
		while(l < q[i].l) addl();
//		if(i%1000 == 0) cerr<<i<<' '<<q[i].l<<' '<<q[i].r<<' '<<l<<' '<<r<<' '<<tot<<'\n';
		ans[q[i].id] = t[1].sum;
	}
	for(int i = 1; i <= Q; i++) {
		cout<<ans[i]<<'\n';
	}
//	cerr<<cnt<<'\n';
}
/*
log*(q/T*n+T*n)
*/
int tt;
int main(){
	freopen("dierti.in","r",stdin); freopen("dierti.out","w",stdout);
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//	int tt; cin >> tt; while(tt--)
//	cerr<<sizeof(t)/1024.0/1024<<'\n';
	cin >> tt;
	Solve();
	return 0;
}


